<div class="page">
    <div class="menu">
		<?php include('modules/members/dashboard.php');?>
    </div>
    <div class="persons">
    <?php
        $sql    = 'SELECT * FROM members WHERE username="'.$_SESSION['user'].'"';
        $q      = $db->select_query($sql);
        $rs     = $db->fetch($q);
    ?>
    <?php if(isset($_GET['action']) && $_GET['action'] == "updated"){
        if($_POST['password'] != ""){
            $sql = 'UPDATE members SET password = "'.md5($_POST['password']).'", name = "'.$_POST['name'].'", mobile = "'.$_POST['mobile'].'" WHERE username = "'.$_SESSION['user'].'"';
        }else{
            $sql = 'UPDATE members SET name = "'.$_POST['name'].'", mobile = "'.$_POST['mobile'].'" WHERE username = "'.$_SESSION['user'].'"';
        }
        $q  = mysql_query($sql)or die(mysql_error());
        if($q){
            echo '<h1 style="color:green;font-size:40px;margin:65px 140px;">
                    <img src="css/images/edit.png">
                   แก้ไขข้อมูลเรียบร้อยแล้ว
                  </h1>';
        }
    }else{ ?>
    <form action="?m=members&p=profile&action=updated" method="post" id="profile_form" >
        <table width="600" border="0" cellpadding="10" >
            <tbody>
                <tr>
                    <td width="200" align="right"><img src="css/images/edit.png" alt="เพิ่มพนักงาน" title="เพิ่มพนักงาน" /></td>
                    <td align="left"><h2>แก้ไขข้อมูลส่วนตัว</h2></td>
                </tr>
                <tr>
                    <td width="200" align="right">ชื่อผู้ใช้งาน </td>
                    <td align="left">
                    <input type="text" name="username" id="username" disabled="disabled" value="<?php echo $rs['username']; ?>"/>
                    </td>
                </tr>
                 <tr>
                    <td align="right">รหัสผ่าน </td>
                    <td align="left"><input type="text" name="password" id="password"/></td>
                </tr>
                <tr>
                    <td align="right">ยืนยันรหัสผ่าน </td>
                    <td align="left"><input type="text" name="confirm_password" id="confirm_password" /></td>
                </tr>
                <!--<tr>
                    <td align="right">อีเมล์ </td>
                    <td align="left"><input type="text" name="email" id="email" value="<?php echo $rs['email'];?>"/></td>
                </tr>-->
                <tr>
                    <td align="right">ชื่อ - นามสกุล </td>
                    <td align="left"><input type="text" name="name" id="name" value="<?php echo $rs['name'];?>"/></td>
                </tr>
                <!--<tr>
                    <td align="right">ที่อยู่ </td>
                    <td align="left"><input type="text" name="address" id="address" value="<?php echo $rs['address'];?>"/></td>
                </tr>
                <tr>
                    <td align="right">ตำบล </td>
                    <td align="left"><input type="text" name="tumbon" id="tumbon" value="<?php echo $rs['tumbon'];?>"/></td>
                </tr>
                <tr>
                    <td align="right">อำเภอ </td>
                    <td><input type="text" name="amphur" id="amphur" value="<?php echo $rs['amphur'];?>"/></td>
                </tr>
                <tr>
                    <td align="right">จังหวัด </td>
                    <td align="left"><input type="text" name="province" id="province" value="<?php echo $rs['province'];?>"/></td>
                </tr>
                <tr>
                    <td align="right">รหัสไปรษณีย์ </td>
                    <td align="left"><input type="text" name="postcode" id="postcode" value="<?php echo $rs['postcode'];?>"/></td>
                </tr>-->
                <tr>
                    <td align="right">เบอร์โทรศัพท์ </td>
                    <td align="left"><input type="text" name="mobile" id="mobile" value="<?php echo $rs['mobile'];?>"/></td>
                </tr>
                <tr>
                    <td align="right"></td>
                    <td align="left">
                        <p style="margin-left:0px;margin-top:25px;" id="button">
                        	<a href="#" class="btn" style="font-size:25px;" id="profile_btn" onClick="return false;">
                        	    <span>แก้ไขข้อมูล</span>
                            </a>
                            <span class="loading"></span>
                       	</p>
       	            </td>
                </tr>
            </tbody>
        </table>
    </form>
    <?php } ?>
    </div>
</div>

